package app.android.com.wuandroidapp.test.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import javax.inject.Inject;

import app.android.com.wuandroidapp.AndroidApplication;
import app.android.com.wuandroidapp.R;
import app.android.com.wuandroidapp.library.activity.BaseNoTitleActivity;
import app.android.com.wuandroidapp.test.activity.HomePageModule.PromodtionModule;
import app.android.com.wuandroidapp.test.activity.component.DaggerPromodtionComponent;
import app.android.com.wuandroidapp.test.contract.PromodtionContract;
import app.android.com.wuandroidapp.test.model.db.entities.minimalist.HelpPromodtionDetail;
import app.android.com.wuandroidapp.test.presenter.PromodtionPresenter;
import butterknife.BindView;
import butterknife.ButterKnife;

public class PromodtionActivity extends BaseNoTitleActivity implements PromodtionContract.View {

    @BindView(R.id.tv_textview)
    TextView tvTextview;
    @Inject
    PromodtionPresenter promodtionPresenter;
    @BindView(R.id.title_text)
    TextView titleText;
    @BindView(R.id.iv_title_right)
    ImageView ivTitleRight;
    private PromodtionContract.Presenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_promodtion);
        ButterKnife.bind(this);
        titleText.setText("云吧");
        DaggerPromodtionComponent.builder()
                .applicationComponent(AndroidApplication.getInstance().getApplicationComponent())
                .promodtionModule(new PromodtionModule(PromodtionActivity.this))
                .build().inject(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        assert presenter != null;
        presenter.subscribe();
    }

    @Override
    public void onPause() {
        super.onPause();
        presenter.unSubscribe();
    }

    @Override
    public void setPresenter(PromodtionContract.Presenter presenter) {
        this.presenter = presenter;
    }

    @Override
    public void displayTestInformation(HelpPromodtionDetail test) {
        tvTextview.setText(test.promotion.name);
    }

    public void back(View v) {
        finish();
    }
}
